package com.xyb.controller;

import com.xyb.service.LoginService;
import com.xyb.utils.CheckUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/code/{iphoneNo}")
    public boolean insertLoginCodeByIphoneNo(@PathVariable("iphoneNo") String iphoneNo){
        //校验手机号
        boolean b = CheckUtils.checkIphoneNo(iphoneNo);
        //业务处理
        boolean flag = loginService.sendLoginCode(iphoneNo);
        return flag;
    }

    @GetMapping("/code/{iphoneNo}/{code}")
    public boolean selectLoginCodeByIphoneNo(@PathVariable("iphoneNo") String iphoneNo,@PathVariable("code") Integer code){
        boolean flag = loginService.selectLoginCodeByIphoneNo(iphoneNo,code);
        return flag;
    }
}